<?php

namespace app\common\validate;

use think\Validate;

class UserAddress extends Validate
{

    /**
     * 验证规则
     */
    protected $rule = [
        'contacts' => 'require',
        'contacts_phone'   => 'require|regex:1[3-9]\d{9}',
        'province_code'=> 'require',
        'city_code'=> 'require',
        'district_code'=> 'require',
        'province_name'=> 'require',
        'city_name'=> 'require',
        'district_name'=> 'require',
        'area'=> 'require',
        'address'=> 'require',
    ];

    /**
     * 提示消息
     */
    protected $message = [
    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'contacts' => '联系人',
            'contacts_phone'   => '联系方式',
            'province_code'=> '所在地区',
            'city_code'=> '所在地区',
            'district_code'=> '所在地区',
            'province_name'=> '所在地区',
            'city_name'=> '所在地区',
            'district_name'=> '所在地区',
            'area'=> '所在地区',
            'address'=> '详细地址',
        ];
        $this->message = array_merge($this->message, [
            'contacts_phone.regex' => '联系方式格式错误',
        ]);
        parent::__construct($rules, $message, $field);
    }

}
